home *** CD-ROM | disk | FTP | other *** search
- /*
- * CatCompiler.ole
- *
- * USAGE: called from the "Configure.ole" module
- *
- * A catalog compiler used for the OLE system. It read the catalog
- * description and write out different files, one for each language. The
- * compiled catalog will be stored in the appropriate directory.
- *
- * HISTORY:
- * v1.01 now each string is "þIDþstring linesÞ"
- *
- * v1.02 a minor update to follow OLE Server v1.10
- *
- * v1.03 now this is an OLE module
- *
- * TODO: put all messages in the localization file
- *
- * $(C): (1994, Rocco Coluccelli, Bologna)
- * $VER: CatCompiler.ole 1.03 (03.Dec.1994)
- */
-
- OPTIONS RESULTS
-
- PARSE ARG oleclip
- PARSE VALUE GETCLIP(oleclip) WITH jobID modID . . . . . oleport olehost userscreen . . locale .
-
- /*
- * strings and messages delimiters
- */
- BS = "þ" /* begin string */
- ES = "Þ" /* end string */
- NL = '0A'x /* new line */
-
- /*
- * characters conversion table
- */
- CO = "," /* comma */
- VI = "¸" /* virgola */
-
- QU = "'" /* quote */
- AP = "´" /* apostrophe */
-
- /*
- * Send commands to OLE server
- */
- ADDRESS VALUE oleport
-
- IF OPENPORT(olehost) == NULL() THEN DO
- ERROR jobID modID 1 olehost
- EXIT 10
- END
-
- INFO jobID modID 'locale.path'
- localepath = GETCLIP(oleclip)
-
-
- DO UNTIL cmd = 'QUIT'
-
- CALL WAITPKT(olehost)
- pkt = GETPKT(olehost)
-
- IF pkt == NULL() THEN ITERATE
-
- PARSE VALUE GETARG(pkt) WITH cmd argv
-
- SELECT
-
- /*
- * COMPILE sourcecat
- */
- WHEN cmd = 'COMPILE' THEN CALL CompileCat(STRIP(argv,'B'))
-
- OTHERWISE NOP
-
- END
-
- CALL REPLY(pkt,0)
-
- END
-
- CALL CLOSEPORT(olehost)
- EXIT 0
-
-
- /*
- * procedure that compile the given catalog source file
- *
- * CompileCat(sourcecat)
- */
- CompileCat:
-
- destcat = SplitPath(LEFT(ARG(1),LENGTH(ARG(1)) - 3)) || '.catalog'
-
- IF ~OPEN(src,ARG(1),'R') THEN DO
- ERROR jobID modID 5 ARG(1)
- RETURN
- END
-
- cat = 0 /* catalog flag */
- str = 0 /* string flag */
- DO UNTIL EOF(src)
-
- line = READLN(src)
- PARSE VAR line head rest .
-
- SELECT
-
- /*
- * skip comment lines
- */
- WHEN head = ';' THEN NOP
-
- /*
- * begin or end of catalog
- */
- WHEN head = '##' THEN DO
-
- IF rest ~= '' & ~cat THEN DO
-
- path = localepath || rest
- IF ~EXISTS(path) THEN CALL MAKEDIR(path)
-
- IF ~OPEN(dst,path || '/' || destcat,'W') THEN DO
- CALL CLOSE(src)
- ERROR jobID modID 4 path || '/' || destcat
- RETURN
- END
-
- CALL PostMsg(100,100,'Writing...\' || path || '/' || destcat ' \',userscreen)
- cat = 1
- END
-
- ELSE DO
- string = Replace(string,CO,VI)
- string = Replace(string,QU,AP)
- CALL WRITELN(dst,string)
- CALL CLOSE(dst)
- CALL PostMsg(100,100,'finished\',userscreen)
- cat = 0
- END
-
- string = ''
- END
-
- /*
- * begin or end of string
- */
- WHEN head = '#' THEN DO
-
- IF rest ~= '' & str = 0 THEN DO
- string = string || BS || UPPER(rest) || BS
- str = 1
- END
-
- ELSE DO
- string = string || ES
- str = 0
- END
-
- END
-
- /*
- * add a new line to the valid string
- */
- WHEN str > 0 THEN DO
-
- IF str = 2 THEN
- string = string || NL || line
-
- ELSE DO
- string = string || line
- str = 2
- END
- END
-
- /*
- * skip invalid lines
- */
- OTHERWISE NOP
-
- END
- END
-
- CALL CLOSE(src)
- CALL PostMsg()
-
- RETURN
-
-
- Replace: PROCEDURE
- PARSE ARG line,old,new
-
- DO FOREVER
- pos = POS(old,line)
- IF pos = 0 THEN LEAVE
- line = OVERLAY(new,line,pos)
- END
-
- RETURN line
-
-
- SplitPath:
-
- RETURN SUBSTR(ARG(1),MAX(POS(':',ARG(1)),LASTPOS('/',ARG(1))) + 1)
-